package org.dromara.system.controller.system;


import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotEmpty;
import lombok.extern.slf4j.Slf4j;

import org.dromara.bean.domain.HisMemberRefund;
import org.dromara.bean.domain.bo.HisGoodsOrderBo;
import org.dromara.bean.domain.vo.HisGoodsOrderVo;
import org.dromara.bean.service.IBaseMemberRefundService;
import org.dromara.common.core.domain.R;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description: 患者退费管理
 * @Author: jeecg-boot
 * @Date: 2020-08-18
 * @Version: V1.0
 */

@RestController
@RequestMapping("/system/memberRefund")
@Slf4j
public class SysMemberRefundController extends BaseController {
    @Autowired
    private IBaseMemberRefundService sysMemberRefundService;

    /**
     * 会员退费管理-分页列表查询
     *
     * @param pageNo
     * @param pageSize
     * @return
     */

    @GetMapping(value = "/list")
    @SaCheckPermission("system:memberRefund:list")
    public TableDataInfo<?> queryPageList(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                          @RequestParam(name = "memberName", defaultValue = "") String memberName,
                                          @RequestParam(name = "doctorName", defaultValue = "") String doctorName,
                                          @RequestParam(name = "status", defaultValue = "") String checkStatus,
                                          @RequestParam(name = "orderType", defaultValue = "") String orderType) {
        return sysMemberRefundService.queryPageList(pageNo, pageSize, memberName, doctorName, checkStatus, orderType);
    }




    /**
     * 患者退费管理-退费审核
     */

    @GetMapping(value = "/audit")
    @SaCheckPermission("system:memberRefund:audit")
    public R<?> audit(@RequestParam(name = "checkStatus", required = true) String checkStatus,
                      @RequestParam(name = "id", required = true) String id,
                      @RequestParam(name = "cause", defaultValue = "") String cause) {
        return sysMemberRefundService.audit(checkStatus, id, cause);
    }



    /**
     * 通过id查询
     *
     * @param id
     * @return
     */
    @GetMapping(value = "/{id}")
    public R<?> queryById(@PathVariable String id) {
        return sysMemberRefundService.queryById(id);
    }




    /**
     * 导出退款订单列表
     */
    @SaCheckPermission("system:memberRefund:export")
    @Log(title = "退款订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HisMemberRefund bo, HttpServletResponse response) {
        List<HisMemberRefund> list = sysMemberRefundService.queryList(bo);
        ExcelUtil.exportExcel(list, "商城订单", HisMemberRefund.class, response);
    }

}
